package com.eclipse.org.snms.serializer.testCase;

import java.util.ArrayList;

import com.eclipse.org.snms.StickyNote;
import com.eclipse.org.snms.TaskComposite;
import com.eclipse.org.snms.serializer.loadStickyNotes.SerializerConcreteSubject;
import com.eclipse.org.snms.serializer.loadStickyNotes.testConcreteObserver;
import com.eclipse.org.snms.serializer.stickyNoteList.StickyNoteList;


import junit.framework.TestCase;
/**
 * 
 * @author jinzi
 *
 */
public class TestLoad extends TestCase {
	StickyNoteList uniquaInstance = StickyNoteList.getUniqueInstance();
	ArrayList <StickyNote> stickyNoteList;
	
	public void testLoad(){		
		TaskComposite task = new TaskComposite();
		int id = 100;
		String title = "TestLoad";
		task.setId(id);
		task.setTitle(title);
		uniquaInstance.addStickyNote(task);		
		SerializerConcreteSubject subject = new SerializerConcreteSubject();
		testConcreteObserver ts = new testConcreteObserver();
		subject.subscribe(ts);
		subject.notifyObservers();	
		stickyNoteList = ts.getStickyNote();	
		//test if the sticky note list of concrete observer is the same 
		//as the sticky note list of class stickyNoteList
		assertEquals(stickyNoteList,uniquaInstance.getStickyNote());
		//test the size
		assertEquals(stickyNoteList.size(),1);
		//test variables 
		TaskComposite taskFromObserver = (TaskComposite)stickyNoteList.get(0);
		assertEquals(taskFromObserver.getId(),id);
		assertEquals(taskFromObserver.getTitle(),title);
		//clear 
		stickyNoteList.clear();
	}
}
